package com.inspire.client01.controller;

import com.inspire.client01.netty.Client;
import com.inspire.client01.tank.Dir;
import com.inspire.client01.tank.Group;
import com.inspire.client01.tank.Tank;
import com.inspire.client01.tank.TankJoinMsg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author ：inspire
 * @date ：Created in 2022/8/12 11:59
 * @description：
 * @modified By：inspire
 * @version:
 */
@RestController
public class Client01Controller {
    private static final Logger logger = LoggerFactory.getLogger(Client01Controller.class);

    static {
        new Thread(()->{
            Client.INSTANCE.connect();
        }).start();

    }

    @RequestMapping("sendDemo")
    public String sendDemo(){
        logger.info("Hello!");

        Client.INSTANCE.send(new TankJoinMsg(new Tank(UUID.randomUUID(),2,2, Dir.DOWN,true, Group.GOOD)));
        return "sendDemo";
    }
}
